<%--
Created by IntelliJ IDEA.
User: wang
Date: 2021/3/16/016
Time: 18:36
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/common/headerAndLeft.jsp" %>
<div class="right">
    <div class="location">
        <strong>你现在所在的位置是:</strong>
        <span>账单管理页面</span>
    </div>
    <div class="search">
        <form action="${ctx}/bill/billList" method="post" id="searchForm" name="searchForm">
            <span>商品名称：</span>
            <input type="text" name="productName" value="${param.productName}" placeholder="请输入商品的名称"/>

            <span>供应商：</span>
            <select name="providerId">
                <option value="0">--请选择--</option>
                <c:forEach items="${providerList}" var="provider">
                    <option value="${provider.id}"
                            <c:if test="${param.providerId==provider.id}">selected</c:if>>
                            ${provider.proName}
                    </option>
                </c:forEach>
            </select>
            <input type="hidden" name="pageIndex" value="1"/>
            <input type="hidden" name="pageSize" value="6"/>
            <%--<input type="reset" value="重置" id="reset1" style="width: 80px;height: 30px;text-align: center;vertical-align: center">--%>
            <span>是否付款：</span>
            <select name="isPayment">
                <option value="0" <c:if test="${param.isPayment==0}">selected</c:if>>--请选择--</option>
                <option value="1" <c:if test="${param.isPayment==1}">selected</c:if>>未付款</option>
                <option value="2" <c:if test="${param.isPayment==2}">selected</c:if>>已付款</option>
            </select>
            <input type="button" value="查询" id="btn1"/>
            <c:if test="${user.userRole!=3}">
                <a href="javaScript:void(0)" class="billAdd">添加订单</a></c:if>
        </form>

    </div>
    <!--账单表格 样式和供应商公用-->
    <table class="providerTable" cellpadding="0" cellspacing="0">
        <tr class="firstTr">
            <th width="10%">账单编码</th>
            <th width="20%">商品名称</th>
            <th width="25%">供应商</th>
            <th width="10%">账单金额</th>
            <th width="10%">是否付款</th>
            <th width="10%">创建时间</th>
            <th width="25%">操作</th>
        </tr>
        <c:if test="${empty pageUtil.lists}">
            <tr>
                <td colspan="5" style="font-size: 16px">查询不到相关信息，请检查检索条件重新检索！</td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </c:if>
        <c:forEach items="${pageUtil.lists}" var="bill" varStatus="counts">
            <tr <c:if test="${counts.count%2 eq 0}"> class="admin-list-td-h2" </c:if>>
                <td>${bill.billCode}</td>
                <td>${bill.productName}</td>
                <td>${bill.proName}</td>
                <td>${bill.totalPrice}</td>
                <td>
                    <c:if test="${bill.isPayment==1}">未付款</c:if>
                    <c:if test="${bill.isPayment==2}">已付款</c:if>

                </td>
                <td>
                    <fmt:formatDate value="${bill.creationDate}" pattern="yyyy-MM-dd"/>
                </td>
                <td>
                    <c:choose>
                        <c:when test="${user.userRole==1}">
                            <a href="${ctx}/bill/view/?id=${bill.id}"><img src="${ctx}/statics/images/read.png" alt="查看"
                                                                           title="查看"/></a>
                            <a href="javaScript:void(0)" id="${bill.id}" class="billUpdate"><img
                                    src="${ctx}/statics/images/xiugai.png" alt="修改" title="修改"/></a>

                            <a href="javaScript:void(0)" class="removeBill" id="${bill.id}"><img
                                    src="${ctx}/statics/images/schu.png" alt="删除" title="删除"/></a>

                        </c:when>
                        <c:when test="${user.userRole==2}">
                            <a href="${ctx}/bill/view/?id=${bill.id}"><img src="${ctx}/statics/images/read.png" alt="查看"
                                                                           title="查看"/></a>
                            <a href="javaScript:void(0)" id="${bill.id}" class="billUpdate"><img
                                    src="${ctx}/statics/images/xiugai.png" alt="修改" title="修改"/></a>
                        </c:when>
                        <c:when test="${user.userRole==3}">
                            没有权限操作
                        </c:when>
                    </c:choose>

                </td>
            </tr>
        </c:forEach>

    </table>

    <%--分页条--%>
    <div class="pageNav" style="margin-top: 50px">
        <c:import url="/common/pageNav.jsp">
            <c:param name="pageIndex" value="${pageUtil.pageIndex}"></c:param>
            <c:param name="pageSize" value="${pageUtil.pageSize}"></c:param>
            <c:param name="totalPageNum" value="${pageUtil.totalPageNum}"></c:param>
            <c:param name="totalCount" value="${pageUtil.totalCount}"></c:param>
        </c:import>
    </div>
    <br/>

    <div class="billUpdateView"></div>
    <div class="billAddView"></div>

    <div class="addView"></div>

</div>
</section>

<%--billAdd--%>
<script type="text/javascript">
    $(function () {
        $(".billAdd").click(function () {
            $(".addVIew").load(
                "${ctx}/bill/toBillAdd"
            );
        });
    });
</script>

<%--billUpdate--%>
<script type="text/javascript">
    $(function () {
        $(".billUpdate").click(function () {
            $(".addVIew").load(
                "${ctx}/bill/toBillUpdate",
                {"id": $(this).attr("id")}
            );
        });
    });
</script>

<%--条件分页查询按钮提交--%>
<script type="text/javascript">
    $(function () {
        $("#btn1").click(function () {
            $("#searchForm").submit();
        });
    });
</script>

<!--点击删除按钮后弹出的页面-->
<div class="zhezhao"></div>
<div class="remove" id="removeBi">
    <div class="removerChid">
        <h2>提示</h2>
        <div class="removeMain">
            <p>你确定要删除该订单吗？</p>
            <a href="#" id="yesBill">确定</a>
            <a href="#" id="no">取消</a>
        </div>
    </div>
</div>

<footer class="footer">
    版权归北大青鸟
</footer>


</body>
</html>